#【练习】房子家具管理系统

class Furniture:
    def __init__(self,name,area):
        self.name=name
        self.area=area
class House:
    def __init__(self,house_type,house_area):
        self.house_type=house_type         #户型
        self.house_area=house_area         #面积
        self.furniture_list=[]                  #家具列表
        print("户型:",self.house_type)
        print("总面积:",self.house_area)

    def add_furniture(self,f):
        if self.house_area > f.area:
            self.furniture_list.append(f)
            self.house_area=self.house_area-f.area
            print(f"{f.name}已添加到房子中")
        else:
            print("房子面积不够")
    def show(self):
        print("剩余面积:",self.house_area)
        for furniture in self.furniture_list:
            print("家具名称:",furniture.name)

if __name__ == '__main__':
    House1=House("一房",20)

    cabinet=Furniture("柜子",5)
    table=Furniture("桌子",3)
    chair=Furniture("椅子",2)

    House1.add_furniture(cabinet)
    House1.add_furniture(table)
    House1.add_furniture(chair)

    House1.show()